install_dirs_with_prefix()
{
    (
        IFS=:
        while read path mode user_id group_id
        do
            mkdir -p "$2$path"
            chmod $mode "$2$path"
            chown $user_id:$group_id "$2$path"
        done
    ) <"$1"
}

install_dirs_in_sysroot()
{
    (
        IFS=:
        while read path mode user_id group_id
        do
            mkdir -p "$2$path"
            chmod $mode "$2$path"
            chown $user_id:$group_id "$2$path"
        done
    ) <"$1"
}

install_dirs()
{
    (
        IFS=:
        while read path mode user_id group_id
        do
            mkdir -p "$path"
            chmod $mode "$path"
            chown $user_id:$group_id "$path"
        done
    ) <"$1"
}

install_files_with_prefix()
{
    (
        IFS=:
        while read path mode user_id group_id
        do
            cp -f "$2$3$path" "$3$path"
            chmod $mode "$3$path"
            chown $user_id:$group_id "$3$path"
        done
    ) <"$1"
}

install_files_in_sysroot()
{
    (
        IFS=:
        while read path mode user_id group_id
        do
            cp -f "$2$path" "$3$path"
            chmod $mode "$3$path"
            chown $user_id:$group_id "$3$path"
        done
    ) <"$1"
}

install_files()
{
    (
        IFS=:
        while read path mode user_id group_id
        do
            cp -f "$2$path" "$path"
            chmod $mode "$path"
            chown $user_id:$group_id "$path"
        done
    ) <"$1"
}

install_links_with_prefix()
{
    (
        IFS=:
        while read path value
        do
            ln -fs "$value" "$2$path"
        done
    ) <"$1"
}

install_links_in_sysroot()
{
    (
        IFS=:
        while read path value
        do
            ln -fs "$value" "$2$path"
        done
    ) <"$1"
}

install_links()
{
    (
        IFS=:
        while read path value
        do
            ln -fs "$value" "$path"
        done
    ) <"$1"
}

elf_strip_with_prefix()
{
    (
        while read path
        do
            strip -s "$2$path"
        done
    ) <"$1"
}

elf_strip_in_sysroot()
{
    (
        while read path
        do
            $cross_dir_root/bin/$gnu_target-strip -s "$2$path"
        done
    ) <"$1"
}

elf_strip()
{
    (
        while read path
        do
            strip -s "$path"
        done
    ) <"$1"
}

remove_files()
{
    (
        IFS=:
        while read path null
        do
		#if the basename is a symbolic link, do not follow it, since
                #that is what we want to remove
		rm -f "$(readlink -m "$(dirname "$path")")/$(basename "$path")" 2>/dev/null >/dev/null
        done
    ) <"$1"
}

remove_dirs()
{
    (
	set +e
        IFS=:
        while read path null null
        do
		rmdir -p --ignore-fail-on-non-empty "$(readlink -m "$path")" 2>/dev/null >/dev/null
        done
	set -e
    ) <"$1"
}

oldest_linux_version_get()
{
    a_major=$(echo $1 | sed -re 's/([[:digit:]])\.([[:digit:]]+)\.([[:digit:]]+)/\1/')
    a_minor=$(echo $1 | sed -re 's/([[:digit:]])\.([[:digit:]]+)\.([[:digit:]]+)/\2/')
    a_micro=$(echo $1 | sed -re 's/([[:digit:]])\.([[:digit:]]+)\.([[:digit:]]+)/\3/')
    b_major=$(echo $2 | sed -re 's/([[:digit:]])\.([[:digit:]]+)\.([[:digit:]]+)/\1/')
    b_minor=$(echo $2 | sed -re 's/([[:digit:]])\.([[:digit:]]+)\.([[:digit:]]+)/\2/')
    b_micro=$(echo $2 | sed -re 's/([[:digit:]])\.([[:digit:]]+)\.([[:digit:]]+)/\3/')

    oldest_linux_version=$1
    if test $a_major -gt $b_major; then
        oldest_linux_version=$2
    fi
    if test $a_minor -gt $b_minor; then
        oldest_linux_version=$2
    fi
    if test $a_micro -gt $b_micro; then
        oldest_linux_version=$2
    fi
}
